package kr.couponplay.android.activity.deal.menu;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Color;
import android.graphics.Typeface;
import android.view.View;

public class SubMenuHelper {
	public static List<SubMenuButton> subMenuButtons = new ArrayList<SubMenuButton>();
	public static int selectedSubMenuButtonIndex = 0;
	
	public static void selectSubMenuButton(int position) {
		selectSubMenuButton(subMenuButtons.get(position).getButton());
	}
	
	public static void selectSubMenuButton(View view) {
		for (int i=0; i<subMenuButtons.size(); i++) {
			SubMenuButton button = subMenuButtons.get(i);
			if (view == button.getButton()) {
				button.getButton().setBackgroundColor(Color.parseColor("#C9C9C9"));	//#C9C9C9
				button.getButton().setTextColor(Color.parseColor("#1A1C22"));	//#1A1C22
				button.getButton().setTypeface(null,Typeface.BOLD);
				selectedSubMenuButtonIndex = i;
			} else {
				button.getButton().setBackgroundColor(Color.parseColor("#F2F2F2"));
				button.getButton().setTextColor(Color.parseColor("#727272"));
				button.getButton().setTypeface(null,Typeface.NORMAL);
			}
		}		
	}
	
	public static boolean isSubMenuButton(View view) {
		for (SubMenuButton button : subMenuButtons) {
			if (view == button.getButton()) {
				return true;
			}
		}
		return false;
	}
	
	public static int getSubMenuButtonPosition(View view) {
		for (int i=0; i<subMenuButtons.size(); i++) {
			if (view == subMenuButtons.get(i).getButton()) {
				return i;
			}
		}
		return 0;
	}
	
	public static void setCategorySubMenuText(String name) {
		SubMenuButton button = subMenuButtons.get(0);
		button.getButton().setText(name);
	}
	
	public static void clear() {
		SubMenuHelper.subMenuButtons.clear();
		SubMenuHelper.selectedSubMenuButtonIndex = 0;
	}
}
